document.addEventListener('DOMContentLoaded', function () {
    document.getElementById('dataForm').addEventListener('submit', function (event) {
        event.preventDefault();
        const inputVal = document.getElementById('inputField').value;
        fetch('/submit', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({ inputField: inputVal }),
        })
            .then(response => response.text())
            .then(data => {
                document.getElementById('result').innerHTML = data;
            })
            .catch((error) => {
                console.error('Error:', error);
            });
    });
});